/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CheckOut.java
 *
 * Created on 2010-feb-26, 10:22:55
 */

package dat215projekt.gui.components;

import dat215projekt.data.IMatDataHandlerExtended;
import java.awt.CardLayout;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import javax.swing.JOptionPane;
import javax.swing.JTabbedPane;
import se.chalmers.cse.dat215.project.CreditCard;
import se.chalmers.cse.dat215.project.Customer;
import se.chalmers.cse.dat215.project.Order;
import se.chalmers.cse.dat215.project.ShoppingCartListener;
import se.chalmers.cse.dat215.project.ShoppingItem;

/**
 *
 * @author Administratör
 */
public class CheckOut extends javax.swing.JPanel implements ShoppingCartListener{
    private static IMatDataHandlerExtended handler = IMatDataHandlerExtended.getInstance();


    private Navigation navigationBar;
    private JTabbedPane paneRef;

    private static final NumberFormat moneyFormat;
    static {
        DecimalFormatSymbols symbols = new DecimalFormatSymbols();
        symbols.setDecimalSeparator(',');
        symbols.setGroupingSeparator(' ');

        moneyFormat = new DecimalFormat("###,##0.00",symbols);
    }

    public void setNavigationRef(Navigation n){
        navigationBar = n;
    }

    public void setTabbedPaneRef(JTabbedPane ref){
        paneRef = ref;
    }

    /** Creates new form CheckOut */
    public CheckOut() {
        initComponents();

        handler.addShoppingCartListener(this);

        CreditCard cc = handler.getCreditCard();
        Customer c = handler.getCustomer();

        // Customer fields
        firstNameField.setText(c.getFirstName());
        lastNameField.setText(c.getLastName());
        adressField.setText(c.getAddress());
        emailField.setText(c.getEmail());
        phoneField.setText(c.getPhoneNumber());
        zipCodeField.setText(c.getPostCode());
        cityField.setText(c.getPostAddress());

        // Customer labels
        firstNameLabel.setText(c.getFirstName());
        lastNameLabel.setText(c.getLastName());
        adressLabel.setText(c.getAddress());
        emailLabel.setText(c.getEmail());
        phoneLabel.setText(c.getPhoneNumber());
        zipCodeLabel.setText(c.getPostCode());
        cityLabel.setText(c.getPostAddress());

        // Creditcard fielsd
        cardNumberField.setText(cc.getCardNumber());
        cardTypeBox.setSelectedItem(cc.getCardType());
        cardHolderField.setText(cc.getHoldersName());
        yearBox.setSelectedItem(new Integer(cc.getValidYear()).toString());
        monthBox.setSelectedItem(new Integer(cc.getValidMonth()).toString());
        cardTypeBox.setSelectedItem(cc.getCardType());
        cwField.setText(cc.getVerificationCode()+"");

        cardNumberLabel.setText(cc.getCardNumber());
        cardTypeLabel.setText(cc.getCardType());
        cardHolderLabel.setText(cc.getHoldersName());
        yearLabel.setText(""+cc.getValidYear());
        monthLabel.setText(""+cc.getValidMonth());
        cardTypeLabel.setText(cc.getCardType());
        cvvLabel.setText(cc.getVerificationCode()+"");

        if(handler.isUserComplete()){
            // Show "no edit" card
            ((CardLayout)customerPanel.getLayout()).show(customerPanel,"card2");

        }
        else{
            ((CardLayout)customerPanel.getLayout()).show(customerPanel,"card3");
        }
    }

    public void shoppingCartChanged() {
        amountLabel.setText(moneyFormat.format(handler.getShoppingCart().getTotal()));
        numProducts.setText(handler.getShoppingCartItems().size()+" st");

        confirmButton.setEnabled(handler.getShoppingCartItems().size() > 0);
    }
     
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING:  public void shoppingCartChanged() {
        amountLabel.setText(moneyFormat.format(handler.getShoppingCart().getTotal()));
        numProducts.setText(handler.getShoppingCartItems().size()+" st");
    }Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jProgressBar1 = new javax.swing.JProgressBar();
        jPanel2 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        amountLabel = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        numProducts = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        confirmButton = new javax.swing.JButton();
        customerPanel = new javax.swing.JPanel();
        editMode = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        phoneField = new javax.swing.JTextField();
        zipCodeField = new javax.swing.JTextField();
        cityField = new javax.swing.JTextField();
        emailField = new javax.swing.JTextField();
        adressField = new javax.swing.JTextField();
        lastNameField = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        firstNameField = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        saveCheckBox = new javax.swing.JCheckBox();
        monthBox = new javax.swing.JComboBox();
        yearBox = new javax.swing.JComboBox();
        jLabel12 = new javax.swing.JLabel();
        cardHolderField = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        cwField = new javax.swing.JTextField();
        cardNumberField = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        cardTypeBox = new javax.swing.JComboBox();
        jLabel31 = new javax.swing.JLabel();
        noEditMode = new javax.swing.JPanel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel30 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        setEditMode = new javax.swing.JButton();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        firstNameLabel = new javax.swing.JLabel();
        lastNameLabel = new javax.swing.JLabel();
        adressLabel = new javax.swing.JLabel();
        zipCodeLabel = new javax.swing.JLabel();
        cityLabel = new javax.swing.JLabel();
        emailLabel = new javax.swing.JLabel();
        phoneLabel = new javax.swing.JLabel();
        cardNumberLabel = new javax.swing.JLabel();
        cvvLabel = new javax.swing.JLabel();
        cardHolderLabel = new javax.swing.JLabel();
        yearLabel = new javax.swing.JLabel();
        monthLabel = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        jLabel32 = new javax.swing.JLabel();
        cardTypeLabel = new javax.swing.JLabel();

        jProgressBar1.setName("jProgressBar1"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(dat215projekt.Dat215projektApp.class).getContext().getResourceMap(CheckOut.class);
        setBackground(resourceMap.getColor("Form.background")); // NOI18N
        setName("Form"); // NOI18N

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel2.setName("jPanel2"); // NOI18N
        jPanel2.setOpaque(false);

        jPanel5.setName("jPanel5"); // NOI18N
        jPanel5.setOpaque(false);

        amountLabel.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        amountLabel.setText(resourceMap.getString("amountLabel.text")); // NOI18N
        amountLabel.setName("amountLabel"); // NOI18N

        jLabel27.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        jLabel27.setText(resourceMap.getString("jLabel27.text")); // NOI18N
        jLabel27.setName("jLabel27"); // NOI18N

        numProducts.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        numProducts.setText(resourceMap.getString("numProducts.text")); // NOI18N
        numProducts.setName("numProducts"); // NOI18N

        jLabel25.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        jLabel25.setText(resourceMap.getString("jLabel25.text")); // NOI18N
        jLabel25.setName("jLabel25"); // NOI18N

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel25)
                    .addComponent(jLabel27))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 110, Short.MAX_VALUE)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(amountLabel)
                    .addComponent(numProducts)))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel25)
                    .addComponent(numProducts))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 16, Short.MAX_VALUE)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel27)
                    .addComponent(amountLabel)))
        );

        confirmButton.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        confirmButton.setText(resourceMap.getString("confirmButton.text")); // NOI18N
        confirmButton.setToolTipText(resourceMap.getString("confirmButton.toolTipText")); // NOI18N
        confirmButton.setName("confirmButton"); // NOI18N
        confirmButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                confirmButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(251, Short.MAX_VALUE)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(confirmButton, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(36, 36, 36)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(confirmButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(46, 46, 46))
        );

        customerPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        customerPanel.setName("customerPanel"); // NOI18N
        customerPanel.setOpaque(false);
        customerPanel.setLayout(new java.awt.CardLayout());

        editMode.setEnabled(false);
        editMode.setName("editMode"); // NOI18N
        editMode.setOpaque(false);

        jLabel8.setFont(resourceMap.getFont("jLabel8.font")); // NOI18N
        jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jPanel3.setName("jPanel3"); // NOI18N
        jPanel3.setOpaque(false);

        jLabel6.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel4.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel5.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel3.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel2.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel7.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        phoneField.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        phoneField.setName("phoneField"); // NOI18N

        zipCodeField.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        zipCodeField.setName("zipCodeField"); // NOI18N

        cityField.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        cityField.setName("cityField"); // NOI18N

        emailField.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        emailField.setName("emailField"); // NOI18N

        adressField.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        adressField.setName("adressField"); // NOI18N

        lastNameField.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        lastNameField.setName("lastNameField"); // NOI18N

        jLabel1.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        firstNameField.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        firstNameField.setText(resourceMap.getString("firstNameField.text")); // NOI18N
        firstNameField.setName("firstNameField"); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel4)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6)
                    .addComponent(jLabel3)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(cityField)
                    .addComponent(emailField)
                    .addComponent(phoneField, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE)
                    .addComponent(adressField)
                    .addComponent(lastNameField)
                    .addComponent(firstNameField)
                    .addComponent(zipCodeField, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(firstNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lastNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addGap(9, 9, 9)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(adressField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(zipCodeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cityField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(emailField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addGap(11, 11, 11)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(phoneField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addContainerGap(60, Short.MAX_VALUE))
        );

        jPanel4.setName("jPanel4"); // NOI18N
        jPanel4.setOpaque(false);

        saveCheckBox.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        saveCheckBox.setText(resourceMap.getString("saveCheckBox.text")); // NOI18N
        saveCheckBox.setName("saveCheckBox"); // NOI18N
        saveCheckBox.setOpaque(false);

        monthBox.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        monthBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "MM", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" }));
        monthBox.setName("monthBox"); // NOI18N

        yearBox.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        yearBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ÅÅ", "10", "11", "12", "13", "14", "15" }));
        yearBox.setName("yearBox"); // NOI18N

        jLabel12.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
        jLabel12.setName("jLabel12"); // NOI18N

        cardHolderField.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        cardHolderField.setText(resourceMap.getString("cardHolderField.text")); // NOI18N
        cardHolderField.setName("cardHolderField"); // NOI18N

        jLabel10.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        jLabel11.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        cwField.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        cwField.setText(resourceMap.getString("cwField.text")); // NOI18N
        cwField.setName("cwField"); // NOI18N

        cardNumberField.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        cardNumberField.setName("cardNumberField"); // NOI18N

        jLabel9.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        cardTypeBox.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        cardTypeBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "VISA", "MASTERCARD" }));
        cardTypeBox.setName("cardTypeBox"); // NOI18N

        jLabel31.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N
        jLabel31.setText(resourceMap.getString("jLabel31.text")); // NOI18N
        jLabel31.setName("jLabel31"); // NOI18N

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel31)
                    .addComponent(jLabel12)
                    .addComponent(jLabel9)
                    .addComponent(jLabel10)
                    .addComponent(jLabel11))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(saveCheckBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cardNumberField, javax.swing.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE)
                    .addComponent(cardHolderField, javax.swing.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(yearBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(monthBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(cwField, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cardTypeBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(cardNumberField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(cwField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(12, 12, 12)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(cardHolderField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(yearBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(monthBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cardTypeBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel31))
                .addGap(18, 18, 18)
                .addComponent(saveCheckBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(61, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout editModeLayout = new javax.swing.GroupLayout(editMode);
        editMode.setLayout(editModeLayout);
        editModeLayout.setHorizontalGroup(
            editModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(editModeLayout.createSequentialGroup()
                .addGroup(editModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, 737, Short.MAX_VALUE)
                    .addGroup(editModeLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        editModeLayout.setVerticalGroup(
            editModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(editModeLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(editModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        customerPanel.add(editMode, "card3");

        noEditMode.setName("noEditMode"); // NOI18N
        noEditMode.setOpaque(false);

        jLabel13.setFont(resourceMap.getFont("jLabel13.font")); // NOI18N
        jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel13.setText(resourceMap.getString("jLabel13.text")); // NOI18N
        jLabel13.setName("jLabel13"); // NOI18N

        jLabel14.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        jLabel14.setText(resourceMap.getString("jLabel14.text")); // NOI18N
        jLabel14.setName("jLabel14"); // NOI18N

        jLabel15.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        jLabel15.setText(resourceMap.getString("jLabel15.text")); // NOI18N
        jLabel15.setName("jLabel15"); // NOI18N

        jLabel30.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        jLabel30.setText(resourceMap.getString("jLabel30.text")); // NOI18N
        jLabel30.setName("jLabel30"); // NOI18N

        jLabel17.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        jLabel17.setText(resourceMap.getString("jLabel17.text")); // NOI18N
        jLabel17.setName("jLabel17"); // NOI18N

        jLabel18.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        jLabel18.setText(resourceMap.getString("jLabel18.text")); // NOI18N
        jLabel18.setName("jLabel18"); // NOI18N

        jLabel19.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        jLabel19.setText(resourceMap.getString("jLabel19.text")); // NOI18N
        jLabel19.setName("jLabel19"); // NOI18N

        jLabel20.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        jLabel20.setText(resourceMap.getString("jLabel20.text")); // NOI18N
        jLabel20.setName("jLabel20"); // NOI18N

        setEditMode.setText(resourceMap.getString("setEditMode.text")); // NOI18N
        setEditMode.setToolTipText(resourceMap.getString("setEditMode.toolTipText")); // NOI18N
        setEditMode.setName("setEditMode"); // NOI18N
        setEditMode.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                setEditModeActionPerformed(evt);
            }
        });

        jLabel21.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        jLabel21.setText(resourceMap.getString("jLabel21.text")); // NOI18N
        jLabel21.setName("jLabel21"); // NOI18N

        jLabel22.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        jLabel22.setText(resourceMap.getString("jLabel22.text")); // NOI18N
        jLabel22.setName("jLabel22"); // NOI18N

        jLabel23.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        jLabel23.setText(resourceMap.getString("jLabel23.text")); // NOI18N
        jLabel23.setName("jLabel23"); // NOI18N

        jLabel24.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        jLabel24.setText(resourceMap.getString("jLabel24.text")); // NOI18N
        jLabel24.setName("jLabel24"); // NOI18N

        firstNameLabel.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        firstNameLabel.setText(resourceMap.getString("firstNameLabel.text")); // NOI18N
        firstNameLabel.setName("firstNameLabel"); // NOI18N

        lastNameLabel.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        lastNameLabel.setText(resourceMap.getString("lastNameLabel.text")); // NOI18N
        lastNameLabel.setName("lastNameLabel"); // NOI18N

        adressLabel.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        adressLabel.setText(resourceMap.getString("adressLabel.text")); // NOI18N
        adressLabel.setName("adressLabel"); // NOI18N

        zipCodeLabel.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        zipCodeLabel.setText(resourceMap.getString("zipCodeLabel.text")); // NOI18N
        zipCodeLabel.setName("zipCodeLabel"); // NOI18N

        cityLabel.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        cityLabel.setText(resourceMap.getString("cityLabel.text")); // NOI18N
        cityLabel.setName("cityLabel"); // NOI18N

        emailLabel.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        emailLabel.setText(resourceMap.getString("emailLabel.text")); // NOI18N
        emailLabel.setName("emailLabel"); // NOI18N

        phoneLabel.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        phoneLabel.setText(resourceMap.getString("phoneLabel.text")); // NOI18N
        phoneLabel.setName("phoneLabel"); // NOI18N

        cardNumberLabel.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        cardNumberLabel.setText(resourceMap.getString("cardNumberLabel.text")); // NOI18N
        cardNumberLabel.setName("cardNumberLabel"); // NOI18N

        cvvLabel.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        cvvLabel.setText(resourceMap.getString("cvvLabel.text")); // NOI18N
        cvvLabel.setName("cvvLabel"); // NOI18N

        cardHolderLabel.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        cardHolderLabel.setText(resourceMap.getString("cardHolderLabel.text")); // NOI18N
        cardHolderLabel.setName("cardHolderLabel"); // NOI18N

        yearLabel.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        yearLabel.setText(resourceMap.getString("yearLabel.text")); // NOI18N
        yearLabel.setName("yearLabel"); // NOI18N

        monthLabel.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        monthLabel.setText(resourceMap.getString("monthLabel.text")); // NOI18N
        monthLabel.setName("monthLabel"); // NOI18N

        jLabel29.setFont(resourceMap.getFont("firstNameLabel.font")); // NOI18N
        jLabel29.setText(resourceMap.getString("jLabel29.text")); // NOI18N
        jLabel29.setName("jLabel29"); // NOI18N

        jLabel32.setFont(resourceMap.getFont("jLabel32.font")); // NOI18N
        jLabel32.setText(resourceMap.getString("jLabel32.text")); // NOI18N
        jLabel32.setName("jLabel32"); // NOI18N

        cardTypeLabel.setFont(resourceMap.getFont("cardTypeLabel.font")); // NOI18N
        cardTypeLabel.setText(resourceMap.getString("cardTypeLabel.text")); // NOI18N
        cardTypeLabel.setName("cardTypeLabel"); // NOI18N

        javax.swing.GroupLayout noEditModeLayout = new javax.swing.GroupLayout(noEditMode);
        noEditMode.setLayout(noEditModeLayout);
        noEditModeLayout.setHorizontalGroup(
            noEditModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(noEditModeLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, 700, Short.MAX_VALUE)
                .addGap(42, 42, 42))
            .addGroup(noEditModeLayout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(noEditModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel17)
                    .addComponent(jLabel20)
                    .addComponent(jLabel24)
                    .addComponent(jLabel23)
                    .addComponent(jLabel21)
                    .addComponent(jLabel18)
                    .addComponent(jLabel19))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(noEditModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(phoneLabel)
                    .addComponent(emailLabel)
                    .addGroup(noEditModeLayout.createSequentialGroup()
                        .addGroup(noEditModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(firstNameLabel)
                            .addComponent(zipCodeLabel)
                            .addComponent(adressLabel)
                            .addComponent(lastNameLabel)
                            .addComponent(cityLabel))
                        .addGap(82, 82, 82)
                        .addGroup(noEditModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel30)
                            .addComponent(jLabel15)
                            .addComponent(jLabel14)
                            .addComponent(jLabel22)
                            .addComponent(jLabel32))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(noEditModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cardTypeLabel)
                            .addGroup(noEditModeLayout.createSequentialGroup()
                                .addComponent(yearLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel29)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(monthLabel))
                            .addComponent(cardHolderLabel)
                            .addComponent(cardNumberLabel)
                            .addComponent(cvvLabel))))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, noEditModeLayout.createSequentialGroup()
                .addContainerGap(601, Short.MAX_VALUE)
                .addComponent(setEditMode)
                .addContainerGap())
        );
        noEditModeLayout.setVerticalGroup(
            noEditModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(noEditModeLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel13)
                .addGap(18, 18, 18)
                .addGroup(noEditModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(noEditModeLayout.createSequentialGroup()
                        .addGroup(noEditModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel24)
                            .addComponent(firstNameLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(noEditModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lastNameLabel)
                            .addComponent(jLabel23))
                        .addGap(12, 12, 12)
                        .addGroup(noEditModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(adressLabel)
                            .addComponent(jLabel21))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(noEditModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(zipCodeLabel)
                            .addComponent(jLabel18))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(noEditModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cityLabel)
                            .addComponent(jLabel19))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(noEditModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel20)
                            .addComponent(emailLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(noEditModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel17)
                            .addComponent(phoneLabel)))
                    .addGroup(noEditModeLayout.createSequentialGroup()
                        .addGroup(noEditModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel30)
                            .addComponent(cardNumberLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(noEditModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel15)
                            .addComponent(cvvLabel))
                        .addGap(12, 12, 12)
                        .addGroup(noEditModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel14)
                            .addComponent(cardHolderLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(noEditModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel22)
                            .addComponent(yearLabel)
                            .addComponent(monthLabel)
                            .addComponent(jLabel29))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(noEditModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel32)
                            .addComponent(cardTypeLabel))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 42, Short.MAX_VALUE)
                .addComponent(setEditMode)
                .addContainerGap())
        );

        customerPanel.add(noEditMode, "card2");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(customerPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 751, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(customerPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents



    private void confirmButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_confirmButtonActionPerformed

        // Testa att användaren fyllt i allt
        // TODOOOOOOOOooo

        // Save customer...
        if(saveCheckBox.isSelected()){
            Customer c = handler.getCustomer();
            c.setFirstName(firstNameField.getText());
            c.setLastName(lastNameField.getText());
            c.setAddress(adressField.getText());
            c.setEmail(emailField.getText());
            c.setMobilePhoneNumber(phoneField.getText());
            c.setPhoneNumber(phoneField.getText());
            c.setPostCode(zipCodeField.getText());
            c.setPostAddress(cityField.getText());

            CreditCard cc = handler.getCreditCard();
            cc.setCardNumber(cardNumberField.getText());
            cc.setCardType(cardTypeBox.getSelectedItem().toString());
            cc.setHoldersName(cardHolderField.getText());
            cc.setVerificationCode(Integer.parseInt(cwField.getText()));


            if(yearBox.getSelectedItem().toString().equals("ÅÅ"))
                cc.setValidYear(0);
            else
                cc.setValidYear(Integer.parseInt(yearBox.getSelectedItem().toString()));


            if(monthBox.getSelectedItem().toString().equals("MM"))
                cc.setValidMonth(0);
            else
                cc.setValidMonth(Integer.parseInt(monthBox.getSelectedItem().toString()));
        }





        Order order = handler.placeOrder();

        // Create order string
        String orderString = "Din order är skickad!\n"
                + "Datum: "+order.getDate()+"\n"
                + "Ordernummer: "+order.getOrderNumber()+"\n\n";

        for(ShoppingItem i : order.getItems())
            orderString += i.getAmount() + "x "+i.getProduct().getName()+"\n";

        orderString += "\nDu kan hitta din order under orderhistorik på hem fliken!";

        // skriv ut OOrder och gå tillbaks till hem tabben
        JOptionPane.showMessageDialog(null, orderString);

        navigationBar.goToShop();
        paneRef.setSelectedIndex(0);
}//GEN-LAST:event_confirmButtonActionPerformed

    private void setEditModeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_setEditModeActionPerformed
        ((CardLayout)customerPanel.getLayout()).show(customerPanel,"card3");
    }//GEN-LAST:event_setEditModeActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField adressField;
    private javax.swing.JLabel adressLabel;
    private javax.swing.JLabel amountLabel;
    private javax.swing.JTextField cardHolderField;
    private javax.swing.JLabel cardHolderLabel;
    private javax.swing.JTextField cardNumberField;
    private javax.swing.JLabel cardNumberLabel;
    private javax.swing.JComboBox cardTypeBox;
    private javax.swing.JLabel cardTypeLabel;
    private javax.swing.JTextField cityField;
    private javax.swing.JLabel cityLabel;
    private javax.swing.JButton confirmButton;
    private javax.swing.JPanel customerPanel;
    private javax.swing.JLabel cvvLabel;
    private javax.swing.JTextField cwField;
    private javax.swing.JPanel editMode;
    private javax.swing.JTextField emailField;
    private javax.swing.JLabel emailLabel;
    private javax.swing.JTextField firstNameField;
    private javax.swing.JLabel firstNameLabel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JProgressBar jProgressBar1;
    private javax.swing.JTextField lastNameField;
    private javax.swing.JLabel lastNameLabel;
    private javax.swing.JComboBox monthBox;
    private javax.swing.JLabel monthLabel;
    private javax.swing.JPanel noEditMode;
    private javax.swing.JLabel numProducts;
    private javax.swing.JTextField phoneField;
    private javax.swing.JLabel phoneLabel;
    private javax.swing.JCheckBox saveCheckBox;
    private javax.swing.JButton setEditMode;
    private javax.swing.JComboBox yearBox;
    private javax.swing.JLabel yearLabel;
    private javax.swing.JTextField zipCodeField;
    private javax.swing.JLabel zipCodeLabel;
    // End of variables declaration//GEN-END:variables

   

}
